//1：统计各种性别的人数，并输出

import jdbc527.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class SexSum {
    public static void main(String[] args) {
        String sql = "select sex, count(stuno) from s_student   GROUP BY sex";
        try {
            Connection con = DBUtil.getConnection();
            PreparedStatement pst = con.prepareStatement(sql);
            ResultSet rs = pst.executeQuery();
            while (rs.next()) {
                System.out.println(rs.getString("sex") + rs.getInt("count(stuno)"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}